//Example 3
//Tests structs and arrays by traversing a simple graph
#include <stdio.h>
#define WriteLine() printf("\n");
#define WriteLong(x) printf(" %lld", (long)x);
#define ReadLong(a) if (fscanf(stdin, "%lld", &a) != 1) a = 0;
#define long long long

struct edge{
	long from;
	long to;
	long w;
} a;

void main(){
	long node;
	long i;
	long j;
	struct edge graph[10];
	graph[0].from = 0;
	graph[0].to = 2;
	graph[0].w = 1;

	graph[1].from = 2;
	graph[1].to = 4;
	graph[1].w = 2;

	graph[2].from = 4;
	graph[2].to = 5;
	graph[2].w = 3;

	graph[3].from = 6;
	graph[3].to = 3;
	graph[3].w = 4;

	graph[4].from = 9;
	graph[4].to = 8;
	graph[4].w = 5;

	graph[5].from = 1;
	graph[5].to = 7;
	graph[5].w = 6;

	graph[6].from = 3;
	graph[6].to = 1;
	graph[6].w = 7;

	graph[7].from = 8;
	graph[7].to = 6;
	graph[7].w = 8;

	graph[8].from = 5;
	graph[8].to = 9;
	graph[8].w = 9;

	graph[9].from = 7;
	graph[9].to = 0;
	graph[9].w = 10;

	node = 0;
	i = 0;
	j = 0;
	while(i < 10){
		while(graph[j].from != node){
			j = j + 1;
		}
		node = graph[j].to;
		WriteLong(graph[j].w);
		WriteLine();
		i = i + 1;
		j = 0;
	}
}

/* Expected output
 1
 2
 3
 9
 5
 8
 4
 7
 6
 10
*/
